<link rel="stylesheet" type="text/css" href="../addons/jy_merch/resource/css/list.css?v=3">
<style>
.myshop-header {border-radius:0.5rem;background:#fff;padding:0.5rem 0.8rem}
.myshop-header .shoplogo {height: 3.5rem; width: 3.5rem; background: #fff; position: absolute; top: 3.5rem; right: 0.8rem; border: 1px solid #eee;border-radius: .2rem}
.myshop-header .shoplogo img {height: 100%; width: 100%; display: block;border-radius: .1rem}
#page-loading .sk-spinner-three-bounce div{background-color: #63BE72}
.sk-spinner-three-bounce div {
	background-color: #63BE72;
}
.btn.btn-danger {
    background: #63BE72;
    border: 1px solid #63BE72;
	
}
.fui-navbar .nav-item.btn {
	font-weight:bold;
    color:#000;
}
.fui-navbar .nav-item.active, .fui-navbar .nav-item:active {
    color: #63BE72;
}
.fui-navbar .nav-item.active .label, .fui-navbar .nav-item:active .label {
    color: #63BE72;
}
.fui-tab.fui-tab-danger a.active {
    border-color: #63BE72;
}
.fui-cell-group .fui-cell.changepwd .fui-cell-text {
    border: 1px solid #63BE72;
    color: #63BE72;
    background: #fff;
}
.fui-cell-group .fui-cell.btn-logout .fui-cell-text {
    background: #63BE72;
}
.btn.btn-danger-o {
    background: transparent;
    color: #63BE72;
    border: 1px solid #63BE72;
}
.text-danger {
    color: #63BE72;
}
.jylabel-red-o.active, .jylabel-red-o:focus, .jylabel-red-o:hover, .jylabel-red-o[href]:focus, .jylabel-red-o[href]:hover {
    border: 1px solid #63BE72;
    color: #63BE72;
}
.order-create-page .no-address {
    color:#63BE72;border: 1px solid #63BE72
}
.fe-floatback a{
    background-color: #fde24d;
	color:#000;
}
.fixed-title {
	color:#63BE72;
}
.red, .red a, .red i {
    color: #63BE72;
}
.fui-fullHigh-item.menu {
    width: 5.25rem;
    background: #f2f2f2;
	color: #333;
}
.fui-fullHigh-item.menu nav.on {
    background: #fff;
    color: #63BE72;
}
.fui-fullHigh-item.menu nav.on:before {
    border-left: 0 solid #ff5555;
}
.parent-category{float:left; width:100%; height:auto; min-height:100%;}
.parent-category ul{margin:0; padding:0; width:100%;}
.parent-category ul li{list-style:none; text-align:center; height:50px; line-height:50px; white-space:nowrap; width:100%; border-bottom:1px solid #e0e0e0; position:relative; right:-1px;}
.parent-category ul li.active{border-right:1px solid #fff; z-index: 10000}
.parent-category ul li a{color:#333; display:inline-block; width:100%; height:100%; text-decoration:none;}
.parent-category ul li.active a{color:#09ba07;}
.children-category{width:100%; min-height:100%; height:auto; color: #252525;}
.children-category ul{list-style:none; margin:0; padding:0; overflow-y:auto; overflow-x:hidden; border-left:1px solid #e0e0e0; min-height:100%;}
.children-category ul li{text-align:left; height: 32px; line-height: 32px; padding-left: 15px}
.children-category ul li.delivery-tips{height:25px; line-height:25px; margin-top: -15px; font-size: .65rem; color: #ff2d4b}
.children-category ul li a{display:inline-block; width:100%; height:100%; text-decoration:none; color:#333;}
.children-category ul li a span{font-size: .6rem; color: #999;}
.children-category .block{display:block; color:#ef1e15; font-size:.6rem;}
.content-group {background:#fff;border-radius: 0.5rem;margin-bottom:0.39rem}
.merchname {display:none}
.fui-tab-scroll .item a {color:#999}
.fui-tab-scroll .item.on,.fui-tab-scroll .item.on a{color:#6a5c4f;}
.fui-tab-scroll .item.on:before {background:linear-gradient(to right,rgba(251,183,26,1),rgba(251,183,26,0));}
.jylabel-red {border: 0 solid #ebebeb;background-color:#fef7dd;color:#c89136}
.yellow {color:#63BE72}
.yellow2 {color:#fff}
.active {
    color: #63BE72;
}
.fui-icon-group .fui-icon-col .text {
    color: #999;
}
.fui-icon-group .fui-icon-col .text.active{
    color:#63BE72
}
.fui-tag-red {
    background: #63BE72;
}
.btn.btn-red-o {
	color: #000;
	border: 1px solid #63BE72;
	background-color:#63BE72;
}
.jylabel-red-0.active,.jylabel-red-0:focus,.jylabel-red-0:hover,.jylabel-red-0[href]:focus,.jylabel-red-0[href]:hover {
	border: 1px solid #63BE72;
	background-color:#fbf4e4;color:ffa000;
	color:#63BE72;
}
.yuyue-duan {background:#fff;border: 0 solid #fff;border-radius: 4px;padding:0.1rem;margin:0.25rem 0.1rem;height:auto;width:auto;font-size:0.6rem;text-align:center}
.yuyue-duan.active{background:#fef7dd;}
.red {
    color: #63BE72;
}
.modal-footer .mod-success {
    background: #63BE72;
	color:#000;
}
.price {color:#333}
.fe-floatback {
    top: 1rem;
}
.dot2{
	background: #eb0101;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.6rem;
    height: 0.8rem;
    line-height: 0.8rem;
    margin-left: 0.1rem;
    min-width: 0.8rem;
    padding: 0 0.2rem;
    position: absolute;
    top: 0;
    left: 0.3rem;
    vertical-align: top;
    text-align: center;
    z-index: 11;
}
.quick-num .plus {
    background: #63BE72;
	color: #000;
}
.quick-num .minus {
    color: #63BE72;
    border: 1px solid #63BE72;
}
.quick-list .quick-item {
	padding:0 0.3rem;
    margin:0;
	box-shadow: 0 0 0 #fff;
}
.quick-list .quick-item .info .title {
    font-size: 0.75rem;
    line-height: 0.9rem;
}
.quick-list .quick-item .info {
    width: 50%;
	align-items: flex-start;
    padding-left: 0.3rem;
    text-align: left;
    font-size: 0.65rem;
}
.quick-list .quick-item .thumb img {height: 4rem;width: 5rem;border-radius:0.1rem}
.quick-list .quick-item .info .buyline {
    height: 1.2rem;
}
.quick-list .quick-item .info .buyline .price {
    color: #333;
    font-size: 0.7rem;
    line-height: 1.2rem;
}
.quick-num .num {
    height: 1.2rem;
    line-height: 1.2rem;
    font-size: 0.65rem;
	width: 0.8rem;
	min-width: 0.8rem;
    padding: 0 0.1rem;
    text-align: center;
    color: #fff;
    opacity: 0;
}
.fui-tab-scroll .item.on:before {content: ""; height: 3px; width: 40%; background: #63BE72; position: absolute; bottom:0; left: 30%}
.fui-footer.quick {box-shadow:0 0 0 rgba(0,0,0,0);height:3rem;background: none;padding:0.2rem 0.5rem}
.fui-footer.quick .quick-cart {
    width:3rem;background: #000;color:#63BE72;border-top-left-radius: 1.35rem;border-bottom-left-radius: 1.35rem;
}
.fui-footer.quick .quick-info{color:#9e9e9e;position: relative;background: #000;padding-left:0;border-left: 0 solid #fff;border-right: 0 solid #fff;}
.fui-footer.quick .quick-info .icon{position: absolute;top:-0.5rem;}
.fui-footer.quick .quick-info.action .icon{color:#63BE72}
.fui-footer.quick .quick-submit {
    height:auto;background: #63BE72;color:#fff;border-top-right-radius: 0;border-bottom-right-radius: 0;
}
.showcode {z-index:118;position:fixed;bottom:3.5rem;right:0;padding:0.15rem 0.3rem;font-size:0.6rem;color:#fff;background-color:{{main.syscolor || '#ff5555'}};border-top-left-radius:1rem;border-bottom-left-radius:1rem;}
</style>
<style type="text/css">
.line-notice {
    position: relative;
	font-size:.75rem;
	padding: 0.35rem 0;
	display: -webkit-box;
	display: -webkit-flex;
	display: -ms-flexbox;
	display: flex;
	-webkit-box-align: center;
	-webkit-align-items: center;
	-ms-flex-align: center;
	align-items: center;
	-moz-transition-duration: 300ms;
	-webkit-transition-duration: 300ms;
	transition-duration: 300ms;
	-webkit-transition-property: background-color;
	transition-property: background-color;
	line-height: 1;
	overflow: hidden;
}
.line-notice .line-notice-label {
	position: relative;
	display: block;
	width: auto;
	color: #666;
}
.line-notice .line-notice-info {
	-webkit-box-flex: 1;
	-webkit-flex: 1;
	-ms-flex: 1;
	flex: 1;
	white-space: nowrap;
	text-overflow: ellipsis;
    overflow: hidden;
	color:#666;
}
.line-notice .line-notice-animation {
	display: flex;
	overflow: hidden;
	margin-left:0.3rem;
	-webkit-box-flex: 1;
	-webkit-flex: 1;
	-ms-flex: 1;
	flex: 1;
	white-space: nowrap;
}
.line-notice .line-notice-remark {
	color: #999;
	text-align: right;
	margin-right: .2rem;
	line-height: 1.1;
}
.line-animation {
    animation: 30s wordsLoop linear infinite normal;
}
@keyframes wordsLoop {
            0% {
                transform: translateX(200px);
                -webkit-transform: translateX(200px);
            }
            100% {
                transform: translateX(-100%);
                -webkit-transform: translateX(-100%);
            }
}
@-webkit-keyframes wordsLoop {
            0% {
                transform: translateX(200px);
                -webkit-transform: translateX(200px);
            }
            100% {
                transform: translateX(-100%);
                -webkit-transform: translateX(-100%);
            }
}
</style>
<div class='fui-page fui-page-current' style="background:#fff">
    <div class="fui-content quick" style="margin-bottom:0;padding-bottom:0">
			<div id="carousel-container" class="carousel slide" data-role="carousel" data-param-auto="true">
				<div class="carousel-inner" role="listbox" style="height:170px">
					<div ng-class="{'item':1, 'active':$index==0}" ng-repeat="nav in pagedata.pluginset.hdps">
						<a ng-click="access_json(nav.url)">
							<img ng-src="{{tomedia(nav.picurl) || '../core/resource/images/banner-1.jpg'}}" style="display: block; width: 100%; height: 100%;">
						</a>
					</div>
				</div>
				<style>
						.fui-swipe-page .fui-swipe-bullet {background: {background}; opacity: {opacity};}
						.fui-swipe-page .fui-swipe-bullet.active {opacity: 1;}
						.fui-swipe-top {height: 14px;position: absolute;left: 0.5rem;top: 0.3rem;color:#fff}
				</style>
				<div ng-if="pagedata.member.nickname" class="fui-swipe-top" style="font-size:0.7rem;"><span>您好！ {{pagedata.member.nickname}}</span></div>
				<div id="carousel-jinyun" class="fui-swipe-page" style="padding: 0 5px; bottom: 10px; ">
					<div class="fui-swipe-bullet" ng-repeat="nav in pagedata.pluginset.hdps" ng-class="{'active':$index==0}" data-target="#carousel-container" data-slide-to="{{$index}}"></div>
				</div>
			</div>
			<div class="myshop-header" style="margin-top:0;padding:0.4rem 0.55rem;position:relative">
					<div class="title bold" style="width:100%;font-size:1rem">{{pagedata.myshop.merchname || '平台自营'}}</div>
					<div class="subtitle" ng-if="pagedata.table.title">桌位：<span>桌台{{pagedata.table.title}}</span></div>
					<div class="subtitle" ng-if="!pagedata.table.title">请扫桌面二维码点餐</div>
					<div class="shoplogo" style="top:-0.6rem">
						<img ng-src="{{tomedia(pagedata.myshop.logo) || '../addons/jy_weishop/images/icon_store.jpg'}}"  />
					</div>
			</div>
            <div class="fui-fullHigh-group">
                <div class="fui-fullHigh-item menu" style="width:4.4rem;padding-top:0.2rem; padding-bottom: 3rem;height: {{page.height?(page.height-60)+'px':'30rem'}};">
					<nav style="line-height: 3;height:auto" ng-click="pagedata.nowckey='all';pagedata.params.pcate='all';pagedata.togroup();" ng-class="{'on':pagedata.nowckey=='all'}">
						<div ng-class="{'subtitle':1,'red':pagedata.nowckey=='all'}" style="line-height:3">全部商品</div>
						<div ng-show="pagedata.allnum>0" class="dot" style="display: block;">{{pagedata.allnum}}</div>
					</nav>
					<nav ng-repeat="item in pagedata.category" style="line-height: 3;height:auto" ng-click="pagedata.nowckey=$index;pagedata.params.pcate=item.id;pagedata.togroup();" ng-class="{'on':pagedata.nowckey==$index}">
						<div ng-class="{'subtitle':1,'red':pagedata.nowckey==$index}" style="line-height:3">{{item.title || '未命名'}}</div>
						<div ng-show="item.total>0" class="dot" style="display: block;">{{item.total}}</div>
					</nav>
				</div>
                <div id="good-liststart" class="fui-fullHigh-item container" style="padding-bottom: 30rem;height: {{page.height?(page.height)+'px':'32rem'}};">
                   <div id="good-list">
					<div ng-repeat="(gkey,g) in pagedata.list" class="quick-list">
						<div ng-if="g.grouptitle" id="group{{g.pcate}}" class="fui-cell-title bold" style="font-size:0.75rem;padding-bottom:0">{{g.grouptitle || '未命名'}} <i class="icon icon-fengexianyou"></i></div>
                        <div id="list">
							    <div class="quick-item">
									<a class="thumb" href="javascript:;" ng-click="pagedata.getgoodsdetail(g.id);" data-nocache="true" style="width:5rem;height:4rem">
										<img ng-src="{{tomedia(g.image) || '../addons/jy_weishop/images/nopic.jpg'}}"/>
									</a>
									<div class="info">
										<div ng-class="{'title overflow-h':1,'yellow':g.id==pagedata.fromgoods.id}">{{g.title}}</div>
										<div style="height:2rem"><span ng-if="g.active.price" style='font-size:0.55rem;color:red;'>{{g.active.title}}</span></div>
										<div class="buyline">
											<span class="price" style="text-align:left;width:auto;font-size:0.5rem">￥<span ng-if="!g.active.price" style="font-size:0.8rem;">{{g.price}}</span><span ng-if="g.active.price" style="font-size:0.8rem;">{{g.active.price}}</span>/{{g.unit || '份'}}</span>
											<div class="buy">
												<div ng-show="(!g.specs_list || g.specs_list.length < 1) && g.total>0" ng-class="{'quick-num':true, 'open':g.carttotal>0}">
													<div ng-click="pagedata.minus(g)" class="minus icon icon-subtract"></div>
													<div class="num" style="color:#999">{{g.carttotal}}</div>
													<div ng-click="pagedata.plus(g)" class="plus icon  icon-tianjia"></div>
												</div>
												<div ng-show="(!g.specs_list || g.specs_list.length < 1) && g.total==0" class="quick-num">
													<div class="btn btn-sm btn-danger disabled" style="line-height:1.4;">已售馨</div>
												</div>
												<div ng-show="g.specs_list.length > 0" ng-class="{'quick-num':true, 'open':g.carttotal>0}">
													<div class="btn btn-sm btn-red-o order-finish" style="line-height:1.4"  ng-click="pagedata.g=g;pagedata.nowgkey=gkey;pagedata.showselecttaocan=true" >选规格</div>
													<div ng-show="g.total" class="dot" style="display: block;">{{g.carttotal}}</div>
												</div>
											</div>
										</div>
									</div>
								</div>
						</div>
                    </div>
					</div>
					<div class="content-empty" ng-if="!pagedata.list || pagedata.list.length<1">
						<i class="icon jinyunicon icon-cry" style="width: 6rem;margin-bottom: 0.5rem;"></i><br/><p style="color: #999;font-size: .75rem">暂时没有商品！</p>
					</div>
                </div>
            </div>
	</div>
	<div ng-if="pagedata.showselecttaocan" class="popup">
		<div class="popup-body">
			<div class="popup-center">
					<div ng-click="pagedata.showselecttaocan=false" class="closebtn syscolor" style="top:0.2rem;right:0.2rem"><i class="icon jinyunicon icon-close" style="font-size:1rem"></i></div>
					<div class="fui-cell-img c" style="padding:1rem;padding-bottom:0.3rem">
						<img style="width:6rem;height:6rem;border-radius: 0.2rem;" ng-src="{{tomedia(pagedata.g.image) || '../core/resource/images/nopic.jpg'}}">
					 </div>
					<div class="fui-cell-title" style="padding-top:0;font-size:0.7rem;border-bottom: 1px solid #f2f2f2;">
									{{pagedata.g.title}}
									<div class="subtitle">
										{{pagedata.g.subtitle || '该商品还没有描述'}}
									 </div>
					</div>
					<div class="row margin0" style="padding-bottom:4.8rem">
									<div ng-repeat="(k,spec) in pagedata.g.specs_list" class="option-picker-cell option spec">
										<div class="fui-cell-group" style="margin-top:0">
											<div class="fui-cell-title subtitle" style="color:#999;font-size:0.6rem">{{spec.title}}</div>
											<div class="fui-cell" style="padding-top:0.2rem">
												<div class="fui-cell-info">
													<span ng-repeat="item in spec.items" ng-class="{'jylabels jylabel-red-o':1,'active':pagedata.g.specid[k]==item.id}" style="line-height:0.8rem;padding: 0.1rem 0.6rem;" ng-click="pagedata.g.specid[k]=item.id;pagedata.get_optionsid();">{{item.title}}</span>
												</div>
											</div>
										</div>
									</div>
					</div>
					<div class="fui-navbar" style="background:#f2f2f2;bottom:2rem;box-shadow:0 0 0 rgba(0,0,0,0);height:2.5rem;">
										<div class="fui-cell-group" style="margin-top:0;background:#f2f2f2;">
											<div class="fui-cell" style="padding-top:0.6rem">
												<div class="fui-cell-info">
													<div class="subtitle"><span class="price" style="color:#000;font-size:0.8rem;line-height:1.2rem">￥{{price(pagedata.g.options.price) || 0.00}}</span>/{{pagedata.g.unit||'份'}}</div>
												</div>
												<div class="fui-cell-remark noremark">
													<div ng-show="pagedata.g.options.stock>0" class="quick-num open" style="text-align:right;">
														<div ng-click="pagedata.sp_minus()" ng-class="{'minus icon icon-subtract':1,'del':pagedata.g.post[pagedata.g.options.id].num==0}" style="background: none;font-size: 0.8rem;"></div>
														<div class="num" style="color:#000">{{pagedata.taocannum}}</div>
														<div ng-click="pagedata.sp_plus()" class="plus icon icon-tianjia" style="border: 1px solid #fff;font-size: 0.8rem;"></div>
													</div>
													<div ng-show="pagedata.g.options.stock==0"></div>
												</div>
											</div>
										</div>
					</div>
					<div class="fui-navbar c sysbgcolor" style="border-bottom-right-radius: 0.2rem;border-bottom-left-radius: 0.2rem;box-shadow:0 0 0 rgba(0,0,0,0);height:2rem;">
										<a ng-show="pagedata.g.options.stock>0" class="nav-item" style="color: #fff;height:2rem;" href="javascript:;" ng-click="pagedata.sp_tocart();">
												加入购物车
											</a>
											<a ng-show="!pagedata.g.options.stock || pagedata.g.options.stock<=0" class="nav-item" style="color: #fff;height:2rem;" href="javascript:;" ng-click="pagedata.showselecttaocan=false">
												已售馨
											</a>
					</div>
				</div>
			</div>
	</div>
	<div ng-if="pagedata.myshop.isrest==0" class="fui-footer quick">
		<p style="font-size:16px;color:#fff;margin-top:8px;width:100%;text-align: center;">商家休息中,暂不接单</p>
	</div>
		<!-- 底部菜单 -->
		<div ng-show="pagedata.showcarts" class="popup">
			<div class="popup-body">
			<div class="popup-bottom">
				<div class="fui-cell-group" style="margin-top:0;padding-top:1rem;margin-bottom:3rem">
					<i ng-click="pagedata.showcarts=false" class="closed icon icon-close red" style="font-size:1rem;"></i>
					<div class="fixed-title">
							 <span class="title-text bold">我的商品</span> 
					</div>
					<div ng-repeat="item in pagedata.carts" ng-if="item.total>0" class="fui-cell">
							<div class="fui-cell-text">
								{{item.title}}<span class="subtitle" ng-if="item.optiontitle">({{item.optiontitle}})</span>
							</div>
							<div class="fui-cell-remark noremark">
								<span class="r-f red" style="margin-right:1rem">￥ {{price(item.price * item.total)}} /{{item.unit ||'件'}}</span>
							</div>
							<div class="fui-cell-remark noremark">
								<div class="quick-num open">
									<div ng-click="pagedata.minus(item,true)" class="minus icon icon-subtract" style="font-size:0.8rem"></div>
									<div class="num" style="color:#333">{{item.total}}</div>
									<div ng-click="pagedata.plus(item,true)" class="plus icon icon-tianjia" style="font-size:0.8rem"></div>
								</div>
							</div>
					</div>
				</div>
			</div>
			</div>
		</div>
		<div ng-if="pagedata.myshop.offline!=1 && pagedata.showlist=='goods'" class="fui-footer quick" style="z-index: 1008;padding:0;height:2.6rem;background: #000;">
				<div class="quick-cart" style="width:4rem">
					<div ng-if="pagedata.allnum>0" class="dot2" style="display: block; top:-0.6rem;left:2.8rem">{{pagedata.allnum}}</div>
					<div ng-click="pagedata.showcarts=true" style="background:#63BE72;border-radius:3rem;width:3rem;height:3rem;line-height:3rem;margin-top:-0.8rem;margin-left:0.5rem">
						<i class="icon icon-cart1" style="color:#fff;line-height:2.8rem;padding:0 0.8rem;font-size:1.4rem;"></i>
					</div>
				</div>
				<div class="quick-info" style="color:#fff;padding-top:0.5rem">
					<div ng-if="pagedata.allnum<=0" style="line-height:1.5rem;">购物车空空如也~~</div>
					<div ng-if="pagedata.allnum>0" style="line-height:0.9rem;">优惠价￥<span style="font-size:0.7rem;font-weight:400">{{pagedata.showprice}}</span></div>
					<div ng-if="pagedata.allnum>0" style="line-height:0.6rem;color:#9e9e9e;font-size:0.5rem">原价￥{{pagedata.oldprice}}</div>
				</div>
				<div ng-if="pagedata.order.id>0 || (pagedata.allnum>0 && pagedata.myshop.out_price<=pagedata.totalprice)" class="quick-submit" style="background:#63BE72" href="javascript:;" ng-click="pagedata.check_buy();">
					{{pagedata.order.id>0 && pagedata.allnum==0?'查看订单':'点好了'}}
				</div>
		</div>
		<div ng-if="pagedata.myshop.offline==1 && pagedata.showlist=='goods'" class="fui-footer" style="box-shadow:0 0 0 rgba(0,0,0,0);height:2.6rem;background: none;padding:0">
			<div class="fui-cellone" style="padding:0;height:2.6rem;background: #333;">
				<div class="fui-cellone-text"style="text-align:center;line-height:1.8rem;height:1.8rem;color:#9e9e9e;font-size:0.8rem">商家休息</div>
			</div>
		</div>
</div>
<div ng-include="sys_html('shop/_goodsdetail','','','jy_weishop')"></div>
<div ng-if="pagedata.bigwheelgames.id>0" class="fe-floatright-bottom" style="bottom:6rem">
	<div class="icon" href="javascript:;" ng-click="access_json('jy_bigwheel/game//merchid='+pagedata.myshop.id+'&id='+pagedata.pagedata.bigwheelgames.id)">
		<img style="width:2rem;height:2rem;border-radius:100%" src="../addons/jy_bigwheel/resource/images/panicon.png">
	</div>
</div>
<div ng-include="sys_html('common/_setmobile')"></div>
<script type="text/javascript">
scope.pagedata.showpingjia=1;
scope.pagedata.taocannum=1;
scope.page.height=window.innerHeight
scope.pagedata.nowckey = 'all';  //状态标记
//刷新总数和总价
scope.pagedata.refresh=function(){
	var allnum=0
	var totalprice=0
	angular.forEach(scope.pagedata.carts,function(cart){
		allnum+=parseInt(cart.total);
		totalprice+=cart.total*cart.price;
	});
	scope.pagedata.allnum=allnum
	scope.pagedata.totalprice=totalprice
	scope.pagedata.showprice=scope.price(scope.pagedata.totalprice);
	scope.pagedata.oldprice=scope.price(scope.pagedata.showprice*1.5);
	scope.$evalAsync();
}
scope.pagedata.goodscroll=function(){
	scope.pagedata.isgoodscroll=true
    $('#good-liststart').scroll(function(event){
		var length=scope.pagedata.grouptops.length
		var indexList=scope.pagedata.grouptops
		if(length>1){
			var grouptop=$("#group"+indexList[1]).offset().top
		}else{
			var grouptop=0;
		}
		if (grouptop>300 && scope.pagedata.nowckey!=0){
              scope.pagedata.nowckey=0;
         }
        if (length >= 3) {
            for (var i = 1; i < length - 1; i++) {
				grouptop=$("#group"+indexList[i]).offset().top
				group2top=$("#group"+indexList[i+1]).offset().top
				//console.log('grouptop'+indexList[i+1]);console.log(grouptop);
                if ((grouptop)<300 && group2top>300 &&  scope.pagedata.nowckey!=i){
                   scope.pagedata.nowckey=i;
                }
            }
        }
		if(length>1){
			grouptop=$("#group"+indexList[length - 1]).offset().top
			if (grouptop<0 && scope.pagedata.nowckey!=length - 1){
				 scope.pagedata.nowckey=length - 1;
			}
		}
		scope.$evalAsync();
    });
}
scope.pagedata.togroup=function(){
	if(scope.pagedata.params.pcate=='all'){
		var id='good-list'
	}else{
		var id='group'+scope.pagedata.params.pcate
	}
	console.log(id)
	setTimeout(function(){
		var element = document.getElementById(id);
		element.scrollIntoView();
		element.scrollIntoView(false);
		element.scrollIntoView({block: "start"});
		element.scrollIntoView({behavior: "smooth", block: "start", inline: "nearest"});
	},200);
}
scope.pagedata.upgrouptop=function(){
	scope.pagedata.grouptops = [];
	var list=scope.pagedata.list
	setTimeout(function(){
		list.forEach(function(row){
			if(row.grouptitle){
				scope.pagedata.grouptops.push(row.pcate); 
			}
		});
		if(!scope.pagedata.isgoodscroll){
			scope.pagedata.goodscroll();
		}
	},200);
}
scope.tool.get_list('jy_merchcmi/myshop/groupslist/',true,function(){scope.pagedata.upgrouptop()});
//减少
scope.pagedata.minus=function(g,iscart){
	var cartid=g.cartid
	var goodsid=g.id;
	var carttotal=g.carttotal;
	if(iscart){
		carttotal=g.total
		cartid=g.id
		goodsid=g.goodsid
	}
	if(carttotal<=0){
		return false;
	}
	console.log(g)
	scope.post_json('jy_weishop/member.cart/minus/',{'merchid':scope.pagedata.myshop.id,'getlist':true,'id':cartid},function(res){
			if(iscart){
				g.total--
				for (j = 0; j < scope.pagedata.list.length; j++) {
						if(scope.pagedata.list[j].id==goodsid){
							scope.pagedata.list[j].carttotal=g.total
							if(g.optionid && scope.pagedata.list[j].post){
								scope.pagedata.list[j].post[g.optionid].num--;
							}
						}
				}
			}
			for (var i = 0; i < scope.pagedata.category.length; i++) {
				if(scope.pagedata.category[i].id==g.pcate){
					scope.pagedata.category[i].total--
				}
			}
			console.log(res.list)
			if(res!='success'){
				g.carttotal--;
				scope.pagedata.carts=res.list
				scope.pagedata.dispatchprice=res.dispatchprice?res.dispatchprice:0;
				scope.pagedata.refresh();
			}
			//console.log(g)
	});
}
//增加
scope.pagedata.plus=function(g,iscart){
	var cartid=g.cartid
	var goodsid=g.id;
	var carttotal=g.carttotal;
	if(iscart){
		carttotal=g.total
		goodsid=g.goodsid
		cartid=g.id
		if(g.optionid>0){
			if(carttotal>=g.options.stock){
				scope.message('不能再添加了，已超过库存！','error');
				return false;
			}
		}else{
			if(carttotal>=g.goodstotal){
				scope.message('不能再添加了，已超过库存！','error');
				return false;
			}
		}
	}else{
		g.optionid=0;
		if(carttotal>=g.total){
			scope.message('不能再添加了，已超过库存！','error');
			return false;
		}
	}	
	scope.post_json('jy_weishop/member.cart/addtocart/',{'getlist':true,'goodsid':goodsid,'optionid':g.optionid,'merchid':scope.pagedata.myshop.id},function(res){
			if(iscart){
				g.total++
				var category=scope.pagedata.category
				for (j = 0; j < scope.pagedata.list.length; j++) {
						if(scope.pagedata.list[j].id==goodsid){
							scope.pagedata.list[j].carttotal=g.total
							if(g.optionid && scope.pagedata.list[j].post){
								scope.pagedata.list[j].post[g.optionid].num++;
							}
						}
				}
			}
			for (var i = 0; i < scope.pagedata.category.length; i++) {
				if(scope.pagedata.category[i].id==g.pcate){
					scope.pagedata.category[i].total++
				}
			}
			if(res!='success'){
				g.carttotal++;
				g.cartid=res.cartid;
				scope.pagedata.carts=res.list
				scope.pagedata.dispatchprice=res.dispatchprice?res.dispatchprice:0;
			}
			//console.log(g)
			scope.pagedata.refresh();
	});
}
//减少
scope.pagedata.sp_minus=function(){
	if(scope.pagedata.taocannum<=1){
		return false;
	}
	scope.pagedata.taocannum --;
	scope.$evalAsync();
}
//增加
scope.pagedata.sp_plus=function(){
	scope.pagedata.taocannum ++;
	scope.$evalAsync();
}
scope.pagedata.sp_tocart=function(){
	var g =scope.pagedata.g;
	if(g.carttotal>=g.options.stock){
		scope.message('不能再添加了，已超过库存！','error');
		return false;
	}
	scope.pagedata.showselecttaocan=false
	scope.post_json('jy_weishop/member.cart/addtocart/',{'getlist':true,'goodsid':g.id,'optionid':g.options.id,'num':scope.pagedata.taocannum},function(res){
			g.carttotal=g.carttotal*1+parseInt(scope.pagedata.taocannum);
			g.post[g.options.id].num=g.post[g.options.id].num*1+parseInt(scope.pagedata.taocannum);
			if(res!='success'){
				g.cartid=res.id;
				scope.pagedata.carts=res.list
			}
			scope.pagedata.category[scope.pagedata.nowckey].total=scope.pagedata.category[scope.pagedata.nowckey].total*1+parseInt(scope.pagedata.taocannum)
			scope.pagedata.goodslist[scope.pagedata.nowgkey]=g
			scope.pagedata.allnum=scope.pagedata.allnum*1+parseInt(scope.pagedata.taocannum)
			scope.pagedata.totalprice+=g.options.price*1
			scope.pagedata.refresh();
	});
}
//选择
scope.pagedata.get_optionsid=function(){
	var specid = scope.pagedata.g.specid;
	specid = specid.join('_');
	scope.pagedata.taocannum=1;
	scope.post_json('jy_merch/goods.detail/get_optionsid/',{'goodsid':scope.pagedata.g.id,'specid':specid,'isdish':1},function(res){
			console.log(res);
			var optionsid=res.options.id;
			scope.pagedata.g.options=res.options;
			scope.pagedata.g.selespename=res.selespename;
			if(res.cartid){
				scope.pagedata.g.cartid=res.cartid;
			}
			if(!scope.pagedata.g.post[optionsid]){
				scope.pagedata.g.post[optionsid]={}
				scope.pagedata.g.post[optionsid]={
					'num':scope.pagedata.g.post[optionsid].num?scope.pagedata.g.post[optionsid].num:res.carttotal,
					'title':res.selespename,
				}
			}
			
			scope.$evalAsync();
	});
}
scope.pagedata.refresh();
scope.pagedata.openLocation=function(item){
	wx.openLocation({
	latitude: item.lat_lng.lat, // 纬度，浮点数，范围为90 ~ -90
	longitude: item.lat_lng.lng, // 经度，浮点数，范围为180 ~ -180。
		name: item.merchname, // 位置名
		address: item.address, // 地址详情说明
		scale: 20, // 地图缩放级别,整形值,范围从1~28。默认为最大
		infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
		success:function(){
			//alert(1111);
		}
	});
}
scope.pagedata.setmerchlike=function(){
	scope.post_json('jy_merch/myshop/like/',{'merchid':scope.pagedata.myshop.id},function(res){
		scope.message(res);
	});
}
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
scope.pagedata.check_buy=function(merchid){
	scope.get('jy_merchcmi/myshop/check_buy/isresurl=1&merchid='+scope.pagedata.myshop.id+'&tableid='+scope.pagedata.tableid,function(resurl){
		scope.access_json(resurl);
	});
}
scope.pagedata.gotop=function(id){
	var ispcate=false
	scope.pagedata.grouptops.forEach(function(pcate){
		if(pcate==id){
			ispcate=true;
		}
	});
	console.log(ispcate);
	if(ispcate){
		if(scope.pagedata.params.pcate){
			scope.pagedata.params.page=1;
			scope.pagedata.params.pcate='';
		}
		console.log(scope.pagedata.params);
	}else{
		scope.pagedata.params.page=1;
		scope.pagedata.params.pcate=id;
		console.log(scope.pagedata.params);
	}
}
</script>